﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QuanLySieuThi.Help;

namespace QuanLySieuThi.GUI
{
    public partial class frmQuanLyKhachHang : Form
    {
        public frmQuanLyKhachHang()
        {
            InitializeComponent();
        }
        public void LoadDS()
        {
            CDataProvider dp = new CDataProvider();
            dp.OpenConnect();
            
            dgvDSKH.DataSource = dp.LoadDS("select * from KhachHang");
        }
        private void frmQuanLyKhachHang_Load(object sender, EventArgs e)
        {
            LoadDS();
            int sl = dgvDSKH.RowCount - 1;
            lbSoLuong.Text = "Số lượng : " + sl.ToString();
        }

        private void dgvDSKH_SelectionChanged(object sender, EventArgs e)
        {
            BUS.CKiemTra kt = new BUS.CKiemTra();
            DTO.CKhachHang kh = new DTO.CKhachHang();
            kh = kt.SelectIndexChangeKhachHang(dgvDSKH);

            txtTenKH.Text = kh.TenKH;
            txtCMND.Text = kh.CMND;
            txtSoDienThoai.Text = kh.SoDienThoai;
            txtDiaChi.Text = kh.DiaChi;
            txtNgaySinh.Text = kh.NgaySinh;
            
            

            
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btnXoa_Click(object sender, EventArgs e)
        {
            int index = dgvDSKH.CurrentRow.Index;
            dgvDSKH.Rows.RemoveAt(index);
        }

        private void btnThem_Click(object sender, EventArgs e)
        {
            
        }
    }
}
